• File: db_run_sql_safe.php
  • Full Path: C:/htdocs/reeft_gps_test/css/include/db_run_sql_safe.php
  • Date Modified: 05/06/2025 7:41 AM
  • File size: 2.22 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php
//======================================================================================
//
// Function: Run a SQL statement against some database
//
// NOTE: config.php must have been include before you include this!
//
// Programmer: JKJ
// Date      : 2022-01-06
//
// ------------------------------------------------------------------------------------------
// One year since the crazy fvcking Trump supporters tried to overcome US democracy.
// FVCK TRUMP AND ALL HIS SUPPORTERS AND DF AND NY BOGERLIGE AND ALL RIGHT WING SHITHEADS!!!!
// ------------------------------------------------------------------------------------------
//
// Copyright Reeft A/S (c) - 2021
//======================================================================================

	if ( $DFT_DATABASE_TO_USE == '*MYSQL') {


		$result = $file_db->prepare( $sql );
		$result->execute();
		$current_elm = $result->rowCount();

		@$last_id = $file_db->lastInsertId();

			// Fetch the next row of a result set as an associative array
			try {

				$data = $result->fetchAll(PDO::FETCH_ASSOC);

			} catch (PDOException $e) {
				//echo "Connection failed: " . $e->getMessage();
			}

	}
	else if ( $DFT_DATABASE_TO_USE == '*MARIA_DB') {


		$result = $file_db->prepare( $sql );
		$result->execute();
		$current_elm = $result->rowCount();

		@$last_id = $file_db->lastInsertId();

			// Fetch the next row of a result set as an associative array
			try {

				$data = $result->fetchAll(PDO::FETCH_ASSOC);

			} catch (PDOException $e) {
				//echo "Connection failed: " . $e->getMessage();
			}

	}
	else
	{

		// Convert to PDO binding format
		$bindings = [];
		
		foreach ($data as $key => $value) {
			$bindings[":$key"] = $value;
		}

		$stmt = $file_db->prepare($sql);
		$stmt->execute($bindings);

		$stmt = $file_db->prepare($sql);
		
		$current_elm = $result->rowCount();

		@$last_id = $file_db->lastInsertId();
		
		// $result = $file_db->prepare( $sql );
		// $result->execute();
		// $current_elm = $result->rowCount();

		// @$last_id = $file_db->lastInsertId();

		// // Fetch the next row of a result set as an associative array
		// $data = $result->fetchAll( PDO::FETCH_ASSOC );

	}


?>